<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="regis.css" type="text/css" charset="utf-8" />
        <title>Register</title>
    </head>

    <script type="text/javascript" src="prototype.js"></script>
    <script type="text/javascript">
        function sub(){
  	//alert(bgsignin);
              var username = $('form2').getInputs("text");
                    //alert(usernam[0].value);
              if(username[0].value==""){
                    alert ("No input Text");
              }
              var email = $('form2').getInputs("text");
                    //alert(email[1].value);
              if(email[1].value==""){
                    alert ("No input Email");
              }
              var password = $('form2').getInputs("password");
                    //alert(password[0].value);
              if(password[0].value==""){
                    alert ("No input password");
              }
              var repassword = $('form2').getInputs("password");
                    //alert(repassword[1].value);
              if(repassword[1].value==""){
                    alert ("No input repassword");
              }
              if(password[0].value!=repassword[1].value){
                    alert ("repassword again");
                    }
              var box = $('form2').getInputs("checkbox");
                    //alert(box[0].checked);
              if(box[0].checked==false){
                    alert ("Please checkbox");
              }

            if((username[0].value!="") && (email[1].value!="") && (password[0].value!="") && (repassword[1].value!="") && (password[0].value==repassword[1].value) && (box[0].checked==true))	{
              document.form2.submit();
            }
}

    </script>

    <body background="image/bgsigninw.png" style="background-repeat: no-repeat">

        <form id="form2" method="POST" name="form2">

            <div id="username">
            <input type="text" name="userregis" value="" />
            </div>

            <div id="email">
                <input type="text" name="email" value="" size="43"/>
            </div>

            <div id="password">
                <input type="password" name="passregis" value="" size="30"/>
            </div>

            <div id="textre">
                Retype password again  :
            </div>

            <div id="repass">
                <input type="password" name="repass" value="" size="30"/>
            </div>

            <div id="ckbox">
            <input type="checkbox" name="ck" value="ON" />
            <div class="style1">I agree to the terms of use.</div>
            </div>

            <div id="passbtt">
                <input type="button" value="Register" name="rebg" onclick="sub(this.value);"/>
            </div>

            <div id="canceltxt">
                <a href="index.php">cancel.</a>
            </div>
            
        </form>

        <div id="status">
<?php
        $userregis = $_POST[userregis];
        //echo $userregis;
        
        $email = $_POST[email];
        //echo $email;

        $pass = $_POST[passregis];
        //echo $pass;

        $repass = $_POST[repass];
        //echo $repass;

        $ck = $_POST[ck];
        //echo $ck;
        $x="0";
	$var="0";

        $link = mysql_connect("localhost","root","");
	mysql_select_db("ilink");
//---------------------email chack-------------------------------------------------------------//
        $result = mysql_query("SELECT email FROM iprofile WHERE email='$email'");

	while($linex = mysql_fetch_array($result)){
	//echo "<email>".$linex['email']."<br>";
	$emailx=$linex['email'];
        //echo $emailx;
	}

        if($emailx){
		echo "not complete . . . . <br> Because email have already. <br>";
                
	}
        else if(!$username && $email){
		//echo "use";
		mysql_query("INSERT INTO iprofile (username,email,password)
		VALUES ('$userregis','$email','$pass')");
		echo "complete . . . ";
		$var="1";
	}
        
        mysql_close($link);
?>
        </div>
        <script type="text/javascript">
		var jsvar = <?php echo $var; ?>;

                //alert(jsvar);
		if(jsvar=="1")
                    
		setTimeout(function(){location.href = "http://localhost/WebiLink/index.php";},3000);
               
        </script>
   </body>
</html>
